#include "modelchoose.h"
#include "ui_modelchoose.h"
#include <QButtonGroup>
#include <modelchooseitem.h>

#define MODEL_TYPE_COUNT_ROW 2
#define MODEL_TYPE_COUNT_COLUMN 3


ModelChoose::ModelChoose(BasicWindow *parent) :
    BasicWindow(parent),
    ui(new Ui::ModelChoose)
{
    ui->setupUi(this);

    init();
}

ModelChoose::~ModelChoose()
{
    delete ui;
}

void ModelChoose::init()
{
    initLayout();
    initItem();
}

void ModelChoose::initLayout()
{
    initTitleBar(this, ":/action/images/companyLogo.png",
                "选择模版", ButtonStyle::CLOSE_BUTTON, QColor(255, 255, 255));
    titleBar->setTitleContent("选择模版", Qt::black);
    titleBar->initStyleSheet(":/action/images/special");
    ui->verticalLayoutTitleBar->addWidget(titleBar);
}

void ModelChoose::initItem()
{
    int count = 1;
    QButtonGroup *buttonGroup = new QButtonGroup(this);
    for (int i = 0; i < MODEL_TYPE_COUNT_ROW; i++) {
        for (int j = 0; j < MODEL_TYPE_COUNT_COLUMN; j++) {
            item = new ModelChooseItem(this);
            item->initRatioButton(count);
            count++;
            item->initPicture();
            buttonGroup->addButton(item->getButton());
            ui->gridLayoutItem->addWidget(item, i, j);
        }
    }
    ui->gridLayoutItem->setMargin(9);
    ui->gridLayoutItem->setSpacing(5);
}
